package com.remenote.remenoteback.entity.vo;

import com.remenote.remenoteback.entity.doo.CommentDo;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;

import java.util.ArrayList;
import java.util.List;

/**
 * @BelongsProject: remenote-back
 * @BelongsPackage: com.remenote.remenoteback.entity.vo
 * @Author: 23392
 * @CreateTime: 2024-03-16  20:43
 * @Description: TODO
 * @Version: 1.0
 */
@Getter
@Setter
@Accessors(chain = true)
public class CommentVo {
    private String publisher;
    private String commentContent;
    private String createTime;

    public static List<CommentVo> formCommentDoList(List<CommentDo> commentDoList) {
        List<CommentVo> commentVos = new ArrayList<>();
        for (CommentDo commentDo : commentDoList) {
            commentVos.add(fromCommentDo(commentDo));
        }
        return commentVos;
    }
    public static CommentVo fromCommentDo(CommentDo commentDo) {
        return new CommentVo().setPublisher(commentDo.getPublisher())
                .setCommentContent(commentDo.getCommentContent())
                .setCreateTime(commentDo.getCreatedTime().toString());
    }
}
